package com.start.shop.common.constant;

import lombok.Data;

/**
 * @Title: MsgObject.java
 * @Package:com.nongxing.task.domain.trans
 * @Description:
 * @author:Fanrg
 * @date:2018-12-19
 * @version:V1.0
 */

@Data
public class MsgObject {

	/** 返回编码 */
	private String code = "";

	/** 返回信息 */
	private String msg = "";

	/** 返回对象 */
	private Object data = null;

	public static final String SUCESS = "000000";

	public MsgObject(String code, String msg, Object data) {
		super();
		this.code = code;
		this.msg = msg;
		this.data = data;
	}

	public MsgObject() {
	}

	public MsgObject(String code, String msg) {
		super();
		this.code = code;
		this.msg = msg;
	}
	
	public static MsgObject success(Object data) {
		return new MsgObject(RspCode.SUCCESS.getCode(), RspCode.SUCCESS.getMessage(), data);
	}
	
	public static MsgObject fail(String code, String msg) {
		return new MsgObject(code, msg, null);
	}

	public static MsgObject fail(RspCode rspCode) {
		return new MsgObject(rspCode.getCode(), rspCode.getMessage(), null);
	}
	
	public static boolean isValid(MsgObject msgObject) {
		if(msgObject.code.equals(SUCESS)) {
			return true;
		}
		else {
			return false;
		}

	}

}
